﻿using Heroius.Extension;
using Heroius.Files;
using System.Collections.ObjectModel;

namespace AlbumDesign
{
    public class Proj : ObservableEntity
    {
        public Proj()
        {
            Album = new Album();
            PhotoPool = new ObservableCollection<PhotoGroup>();
            Navi = new Navigator<AlbumPage>(Album.Pages);
        }

        public void ResetNew()
        {
            Album.Reset();
            PhotoPool.Clear();
        }

        [EntitySilo]
        public Album Album { get; set; }
        [EntitySilo]
        public ObservableCollection<PhotoGroup> PhotoPool { get; set; }

        public void WithdrawPhotos()
        {
            foreach (var p in Album.Pages)
            {
                foreach (var ph in p.Photoes)
                {
                    PhotoPool.AddPhoto(ph);
                }
                p.Photoes.Clear();
            }
        }

        public Navigator<AlbumPage> Navi { get; set; }

        public void MovPhotoFromPoolToPage(Photo photo)
        {
            PhotoPool.RemovePhoto(photo);
            Navi.CurrentPage.Photoes.Add(photo);
        }

        public void MovPhotoFromPageToPool(Photo photo)
        {
            Navi.CurrentPage.Photoes.Remove(photo);
            PhotoPool.AddPhoto(photo);
        }
    }
}
